<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>登陆--首页</title>
<!--[if lt IE 9]>
  <script src="libs/html5shiv.min.js"></script>
  <script src="libs/respond.min.js"></script>
  <![endif]-->
<script src="libs/jquery-1.12.1.min.js"></script>
<link href="libs/bootstrap-3.3.6/css/bootstrap.min.css" rel="stylesheet">
<script src="libs/bootstrap-3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
	<div class="container">
		<div class="row">
			<div class="page-header">
				<h2>
					<strong>小超记账</strong>
				</h2>
			</div>
		</div>
	</div>
	<div class="container">
		<div class="row">
			<div class="col-md-8">
				<ul class="nav nav-pills pull-right">
					<li role="presentation" class="active"><a href="index.html">首页</a></li>

					<li role="presentation"><a href="adda.html">添加档案</a></li>
					<li role="presentation"><a href="query.html">统计</a></li>
					<li role="presentation"><a href="select.html">查询</a></li>
					<button id="query_null">退出</button>

					<li><a href="#">用户： <span id="text3"> </span>
					</a></li>
				</ul>
				<div class="col-md-4" id="search-box-archive"></div>
			</div>
		</div>
		<div class="row">
			<div class="col-md-12">
				<hr />
			</div>
		</div>
	</div>
	<div class="containner">
		<div class="row">
			<div class="col-md-12">

				<hr />
			</div>
		</div>
	</div>
	<div class="container">
		<div class="row">
			<div class="col-md-4">
				<div class="panel panel-primary">
					<div class="panel-heading">最近的收入</div>
					<div class="panel-body">
						<h1 id="text1"></h1>
					</div>
				</div>
			</div>



			<div class="col-md-4">
				<div class="panel panel-success">
					<div class="panel-heading">最近的支出</div>
					<div class="panel-body">
						<h1 id="text2"></h1>
					</div>
				</div>
			</div>
		</div>


	</div>
	<div class="col-md-6"></div>
	</div>
	<div class="row">
		<div class="col-md-12">
			<div class="panel panel-warning">
				<div class="panel-heading">最近四笔收入</div>
				<div class="panel-body" id="list"></div>
			</div>
		</div>
	</div>
	<div class="col-md-12">
		<div class="col-md-12" id="list2">

			<p class="text-center">
				<br />
			<hr />
			<strong>最近四笔支出</strong>
			<svg style="height: 480px; width: 100%"></svg>
			<br />
		</div>
	</div>


	<script type="text/javascript">
		$(function() {

			$('#query_null').click(function() {
				$.post('query_null.action', {

				}, function(res, status) {
					if ('OK' == res) {
						alert('小子哪里跑');
					} else if ('ERR' == res) {
						alert('退出失败');

					}
					window.location.href = "login.html"

				});
			});

			$.getJSON('query_in.action', function(res) {
				console.log(res);
				$('#text1').text(res.su);
			});

			$.getJSON('query_out.action', function(res) {
				console.log(res);
				$('#text2').text(res.s);
			});
			$.getJSON('query_nickname.action', function(res) {
				console.log(res);
				$('#text3').text(res.n);
			});
			$.getJSON('query_c.action', function(res) {
				console.log(res);
				var data = {
					'item' : res
				};
				var t = Handlebars.compile($('#template').html());
				$('#list').html(t(data));
			});
			$.getJSON('query_v.action', function(res) {
				console.log(res);
				//res存在 json里  再把res存在item（json）里面  
				var data = {
					'item' : res
				};
				//调用Handlebars里面compile的这个方法，把 template 显示出来
				var t = Handlebars.compile($('#template').html());
				//必须需要 这样的形式 ：[{"fm":"300"},{"fm":"400"}]  才能显示出来 
				$('#list2').html(t(data));
			});
		});
	</script>

	<script type="text/javascript" src="libs/handlebars.min.js">
		
	</script>
	<script id="template" type="text/x-handlebars-template">
	{{#each item}}
		<div class="panel panel-default col-md-3">
			<div class="panel-body">
				<dl>
					<dt>时间</dt><dd>{{date_time}}</dd>
					<dt>地点</dt><dd>{{place}}</dd>
					<dt>金额</dt><dd>{{money}}</dd>
					<dt>类别</dt><dd>{{kind}}</dd>
				</dl>
			</div>
		</div>
	{{/each}}
</script>
</body>
</html>